<?php
namespace BP\En;
class EntityNo extends Entity {
	public function getPK () 
	{
		return "No";
	}
	public function getNo () 
	{
		return $this->GetValStringByKey(EntityNoNameAttr::$No);
	}
	public function setNo ($value) // [String value]
	{
		$this->SetValByKey(EntityNoNameAttr::$No, $value);
	}
	protected function beforeInsert () 
	{
		$attr = $this->getEnMap()->GetAttrByKey("No");
		if ((((($attr->getUIVisible() ==  TRUE ) && $attr->getUIIsReadonly()) && $this->getEnMap()->getIsAutoGenerNo()) && ($this->getNo()->length() == 0)))
		{
			$this->setNo($this->getGenerNewNo());
		}
		return parent->beforeInsert();
	}
	public static function constructor__ () 
	{
		$me = new self();
		return $me;
	}
	public static function constructor__String ($_no) // [String _no]
	{
		$me = new self();
		if ((($_no . NULL) . $_no->equals("")))
		{
			throw new \RuntimeException(((($me->getEnDesc() . "@对表[") . $me->getEnDesc()) . "]进行查询前必须指定编号�??"));
		}
		$me->setNo($_no);
		if (($me->Retrieve() == 0))
		{
			throw new \RuntimeException((((("@没有" . $me->get_enMap()->getPhysicsTable()) . ", No = ") . $me->getNo()) . "的记录�??"));
		}
		return $me;
	}
	public function Save () 
	{
		if ($this->getIsExits())
		{
			return $this->Update();
		}
		else
		{
			if (($this->getEnMap()->getIsAutoGenerNo() && $this->getEnMap()->GetAttrByKey("No")->getUIIsReadonly()))
			{
				$this->setNo($this->getGenerNewNo());
			}
			$this->Insert();
			return 0;
		}
	}
	public function getGenerNewNo () 
	{
		return $this->GenerNewNoByKey("No");
	}
	public function GenerNewEntityNo () 
	{
		return $this->GenerNewNoByKey("No");
	}
	public function RetrieveByNo () 
	{
		$qo = QueryObject::constructor__($this);
		$qo->AddWhere_String_String(EntityNoAttr::$No, $this->getNo());
		return $qo->DoQuery();
	}
	public function RetrieveByNo_String ($_No) // [String _No]
	{
		$this->setNo($_No);
		$qo = QueryObject::constructor__($this);
		$qo->AddWhere_String_String(EntityNoAttr::$No, $this->getNo());
		return $qo->DoQuery();
	}
}
?>
